package com.portalEsporteClubeBahia.app.vo;

import java.io.Serializable;
import java.sql.Time;
import java.text.SimpleDateFormat;
import java.util.Date;

public class MediaVO implements Serializable {

	private static final long serialVersionUID = -5949952886145829999L;
	
	private Long id;
	
	private String title;
	
	private String urlMedia;
	
	private String shortContent;
	
	private Date date;
	
	private Boolean active;
	
	private TypeMediaVO typeMedia;
	
	private Time time;
	
	private Integer ranking;
	
	private String dateStringStarts;
	
	private String dateStringEnds;
	
	private String timeString;
	
	public MediaVO(){
		this.typeMedia = new TypeMediaVO();
		this.active = true;
	}

	public Long getId() {
		return id;
	}

	public void setId(Long id) {
		this.id = id;
	}

	public String getTitle() {
		return title;
	}

	public void setTitle(String title) {
		this.title = title;
	}

	public String getUrlMedia() {
		return urlMedia;
	}

	public void setUrlMedia(String urlMedia) {
		this.urlMedia = urlMedia;
	}

	public String getShortContent() {
		return shortContent;
	}

	public void setShortContent(String shortContent) {
		this.shortContent = shortContent;
	}

	public Date getDate() {
		return date;
	}

	public void setDate(Date date) {
		this.date = date;
	}

	public Boolean getActive() {
		return active;
	}

	public void setActive(Boolean active) {
		this.active = active;
	}

	public TypeMediaVO getTypeMedia() {
		return typeMedia;
	}

	public void setTypeMedia(TypeMediaVO typeMedia) {
		this.typeMedia = typeMedia;
	}
	
	public String getDateFormat(){
		SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd hh:mm");
		try{
			return sdf.format(date);
		}catch(Exception e){
			return "";
		}
	}

	public Time getTime() {
		return time;
	}

	public void setTime(Time time) {
		this.time = time;
	}
	
	@SuppressWarnings("deprecation")
	public String getTimeFormat(){
		
		String timeFormat = "";
		
		if(this.time.getHours()<10){
			timeFormat = timeFormat + "0" + String.valueOf(this.time.getHours());
		}else{
			timeFormat = timeFormat + String.valueOf(this.time.getHours());
		}
		
		if(this.time.getMinutes()<10){
			timeFormat = timeFormat + ":0" + String.valueOf(this.time.getMinutes());
		}else{
			timeFormat = timeFormat + ":" + String.valueOf(this.time.getMinutes());
		}
		
		if(this.time.getSeconds()<10){
			timeFormat = timeFormat + ":0" + String.valueOf(this.time.getSeconds());
		}else{
			timeFormat = timeFormat + ":" + String.valueOf(this.time.getSeconds());
		}
		
		return timeFormat;
	}

	public Integer getRanking() {
		return ranking;
	}

	public void setRanking(Integer ranking) {
		this.ranking = ranking;
	}

	public String getDateStringStarts() {
		return dateStringStarts;
	}

	public void setDateStringStarts(String dateStringStarts) {
		this.dateStringStarts = dateStringStarts;
	}

	public String getDateStringEnds() {
		return dateStringEnds;
	}

	public void setDateStringEnds(String dateStringEnds) {
		this.dateStringEnds = dateStringEnds;
	}
	
	public String getDateStringStartsFormat(){
		try{
			String date = "";
			String[] array = this.dateStringStarts.split("/");
			date = array[2]+"-"+array[1]+"-"+array[0];
			
			return date;
		}catch(Exception e){
			return null;
		}
	}
	
	public String getDateStringEndsFormat(){
		try{
			String date = "";
			String[] array = this.dateStringEnds.split("/");
			date = array[2]+"-"+array[1]+"-"+array[0];
			
			return date;
		}catch(Exception e){
			return null;
		}
	}

	public String getTimeString() {
		return timeString;
	}

	public void setTimeString(String timeString) {
		this.timeString = timeString;
	}

}
